home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / ARRSUM_I.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  76 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   ARRSUM_I.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22.  
  23. COLOR 7, 0
  24. CLS
  25. ? "┌──────────────────────────────────────────────────────────────────────────
  26. ? "│ fArrSumI?? ( ANYnumber, Els2Count%, StopAtSum??, ElsCounted%, StepSize% )
  27. ? "├──────────────────────────────────────────────────────────────────────────
  28. ? "│ fArrSumI can count the elements of an array or a type. There are some natural
  29. ? "│ restrictions to the total and number of elements counted, etc. but they are
  30. ? "│ sufficiently high to allow for it's use under most circumstances. If you
  31. ? "│ assign a value of ZERO to StopAtSum?? fArrSumI will total all the elements,
  32. ? "│ but if it's value is > ZERO then fArrSumI will stop counting at the element
  33. ? "│ that offers a total =< StopAtSum?? and will return the number of elements
  34. ? "│ counted in ElsCounted%. StepSize% controls the number of bytes `skipped`
  35. ? "│ between the counted elements. ie: a one dimension integer array requires a
  36. ? "│ step size of +/- 2 (2 bytes) where a TYPE could be almost any number.
  37. ? "└───────────────────────────────────────────────────────────────────────────────"
  38.                                                   '┌────────────────────────
  39. RESTORE WEEKDAYS                                  '│
  40.   DIM WeekDay(0:6) AS STRING                      '│ DOS uses ZERO for Sunday
  41.   FOR X% = 1 TO 6                                 '│ so we do the same just
  42.     READ WeekDay$( X% )                           '│ to keep in step!
  43.   NEXT                                            '│
  44. PRINT "TIME CARDS   W06    W07  TOTAL"            '│
  45. PRINT "──────────────────────────────"            '│
  46.                                                   '│
  47. RESTORE MINUTESWORKED                             '│
  48.   DIM T(0:6,1:53) AS INTEGER                      '│ Note how T%() has been
  49.   FOR X% = 1 TO 6                                 '│ DIMed with the days 1st
  50.     READ T%(X%,6)                                 '│ This causes the data to
  51.     READ T%(X%,7)                                 '│ be stored SMTWTFSSMTWTFS
  52.     PRINT WeekDay$( X% );                         '│ while the 2ed element
  53.     PRINT USING "   ###    ###";T%(X%,6),T%(X%,7) '│ points to Sunday of the
  54.   NEXT                                            '│ week number.
  55.                                                   '│
  56.   W6?? = fArrSumI??( T%(0,6), 7, 0, 0, 2 )        '│ get the total for each
  57.   W7?? = fArrSumI??( T%(0,7), 7, 0, 0, 2 )        '│ week
  58.   PRINT "──────────────────────────────"          '│
  59.   PRINT USING "TOTALS:    #,###  #,###";W6??,W7?? '│
  60.   FOR D% = 1 TO 6                                 '│ get the totals for each
  61.     Dt?? = fArrSumI??( T%(D%,6), 2, 0, 0, 14 )    '│ week day for both weeks
  62.     LOCATE (D%+16), 26                            '│ 7days x 2byte = 14
  63.     PRINT USING "#,###"; Dt??                     '│
  64.   NEXT                                            '│
  65.   Tt?? = fArrSumI??( T%(0,6), 14, 0, 0, 2 )       '│ total of both weeks
  66.   LOCATE 24, 26 : PRINT USING "#,###"; Tt??       '│
  67.                                                   '│
  68. '──────────────────────────────────────────────────┼─────────────────────────
  69. '──────────────────────────────────────────────────┼─────────────────────────
  70. WEEKDAYS:                                         '│ DATA STATEMENTS
  71.   DATA "   MONDAY:", "  TUESDAY:", "WEDNESDAY:"   '│
  72.   DATA " THURSDAY:", "   FRIDAY:", " SATURDAY:"   '│
  73. MINUTESWORKED:                                    '│
  74.   DATA 471, 481, 479, 482, 477, 122               '│
  75.   DATA 471, 481, 479, 482, 477,   0               '│
  76.